<html>

<head>
    <link rel="stylesheet" type="text/css" href={{url_for("static",filename="css/sartical.css")}} />
    <!--网页标题设置-->
    <title>远程服务器（CentOS）笔记</title>
    <link rel="shortcut icon" href={{url_for("static",filename="icon/131253281571.jpg")}}>
    <!--meta块-->
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="120">
</head>

<body>
    <h1>远程服务器（CentOS）笔记</h1>
    <h2>服务器部分</h2>
    <p>记得搞密匙连接，密码连接改密匙得重装系统，<s>而某些商家嘛（补你🐎差价.jpg）</s> 他🐎复活了，重装系统后得把盘容量提高到原来的容量他才会显示0差价，就很神必 </p>
    <h2>Apache部分</h2>
    <h3>apache安装</h3>
    <p>yum install httpd -y</p>
    <p>systemctl start httpd.service #启动服务，enable是自启动,restart是重启</p>
    <h3>环境配置</h3>
    <p>/etc/httpd/conf.httpd.conf</p>
    <h3>tmp文件夹</h3>
    <ul>
        <li>根目录下tmp文件夹用于存储临时文件，httpd服务接收的文件会存在该目录下专用的临时文件夹中的tmp中</li>

    </ul>
    <ul>
        <li>
            <p>vim /usr/lib/systemd/system/httpd.service将PrivateTmp=true改成false可直接存在tmp中而非专用子目录</p>
            <p>（需要重启服务：</p>
            <p>systemctl daemon-reload</p>
            <p>systemctl restart httpd.service</p>
            <p>）</p>
        </li>

    </ul>
    <h2>PIP</h2>
    <h3>用pip下载</h3>
    <ul>
        <li>pip推荐国内镜像（例如下面的清华源）</li>

    </ul>
    <pre><code>pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
</code></pre>
    <br>
    <p>也可以直接设置pip全局下载源为镜像站（如清华）</p><pre><code>pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple</code></pre>
    <p>若镜像站没有可取消</p><code>pip config unset global</code>
    <h3>安装pip</h3>
    <ul>
        <li>下载安装脚本get-pup.py</li>

    </ul>
    <p>wget https://<a
            href='https://so.csdn.net/so/search?q=bootstrap&amp;spm=1001.2101.3001.7020'>bootstrap</a>.pypa.io/get-pip.py
    </p>
    <ul>
        <li>
            <p>执行脚本</p>
            <p>py3 get-pip.py</p>
            <p>（python3的指令改为了py3——python2为python，一些过期攻略还在用python命令，你用python3的照着用会懵逼）</p>
            <p>&nbsp;</p>
        </li>

    </ul>
    <p>&nbsp;</p>
    <h2>命令部分</h2>
    <p>chmod 755 #赋予cgi的py文件权限（服务端可访问可执行，浏览器段可访问），不chmod——<strong>500</strong>警告！</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <h2>虚拟环境部分</h2>
    <h3>安装</h3>
    <pre><code class='language-shell' lang='shell'>python3 -m venv venv
</code></pre>
    <h3>激活</h3>
    <pre><code class='language-shell' lang='shell'>. venv/bin/activate
</code></pre>
    <h3>关闭</h3>
    <p>deactivate</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <h2>兼容性部分</h2>
    <p>windows下文件在linux环境下有\r，推荐直接在linux里touch个再复制粘贴，或者notepad++里替换掉\r再复制</p>
    <p><strong>utf-8!</strong></p>
    <p>&nbsp;</p>
    <h2>数据库部分</h2>
    <h3>安装方法1</h3>
    <p>找个文件夹然后wget http://repo.mysql.com/mysql-community-release-xxx.rpm（去<a href="https://dev.mysql.com/downloads/repo/yum/">mysql官网</a>,找到自己版本的rpm文件名（小字），替换上面链接‘com/’后）</p>
    <p>接着yum install mysql80-xxxx.rpm安装安装包</p>
    <p>yum repolist enabled | grep &quot;mysql.<em>-community.</em>&quot; 检查安装情况</p>
    <p>yum module disable mysql 禁用CentOS自带的mysql</p>
    <p>yum install mysql-community-server安装</p>
    <p>chown -R mysql:mysql /var/lib/mysql</p>
    <p>systemctl start mysqld启动</p>
    <p>systemctl status mysqld 状态</p>
    <p>grep 'temporary password' /var/log/mysql/mysqld.log查看初始密码</p>
    <p>mysql -u root -p登录</p>
    <p>ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;xxxxxx&#39;;修改密码</p>
    <p>create user &#39;root&#39;@&#39;%&#39; identified by &#39;root123&#39;;</p>
    <p>grant all privileges on *.* to &#39;root&#39;@&#39;%&#39; with grant
        option;授权远程访问（云服务器那儿的防火墙配置记得加个规则（允许懂得都懂的那个端口。。。））</p>
    <p>&nbsp;</p>
    <h3>安装方法2</h3>
    <pre><code class='language-shell' lang='shell'># rpm -ivh https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpmdev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
</code></pre>
    <pre><code class='language-shell' lang='shell'># yum repolist all | grep mysql | grep enabled
</code></pre>
    <pre><code class='language-shell' lang='shell'># yum --disablerepo=AppStream install -y mysql-community-server
</code></pre>
    <h3>启动不能问题</h3>
    <p>Status: &quot;Data Dictionary upgrade from MySQL 5.7 in progress&quot;</p>
    <p>&nbsp;</p>
    <ol>
        <li>可以检查权限 ls -l /var/lib/ | grep mysql，没有则赋予chmod -R 777 /var/lib/mysql</li>

    </ol>
    <ol start='2'>
        <li>rm -rf /var/lib/mysql/*</li>
        <li>再次启动mysqld</li>
        <li>systemctl status mysqld.service查看状态</li>

    </ol>
    <p>&nbsp;</p>
    
    <p>&nbsp;</p>
    <h3>本地数据库连接服务器mysql</h3>
    <p>（参考<a href='https://www.cnblogs.com/chengxs/p/8142696.html'>本地如何操作服务器的mysql，详细教程 - saucxs - 博客园
            (cnblogs.com)</a>）
    </p>
    <p>&nbsp;</p>
    <p>（创建分配用户和host后）服务器段刷新权限</p>
    <pre><code class='language-mysql' lang='mysql'>flush privileges;
</code></pre>
    <p>&nbsp;</p>
    <p>本地段mysqlworkbench里建立新连接（hostname填云服务器外网ip），记得输入密码，然后configure server management</p>
    <p>服务器防火墙添加3306端口通过情况下，第一步无事发生</p>
    <p>第二步选择SSH连接，然后选操作系统（如openos/linux）</p>
    <p>第三步输入服务器公网ip+端口（不是3306，其他开放的，比如22），用户名+密码（服务器系统的，用于SSH验证），如果服务器是密匙连接就找之前载的密匙文件（.pem）（什么？你没有？那你之前是怎么连的？）</p>
    <p>&nbsp;</p>
    <a href="/cgi-bin/artical.py">
        <p style="text-align: center;color:aquamarine">返回文章目录</p>
    </a>
</body>

</html>